-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(log): refactor some logs #1899
Conversation
ac3801e (Ramkumar Chinchani 2021-12-13 19:23:31 +0000)│ 1224 rh.c.Log.Info().Int64("r.ContentLength", request.ContentLength).Msg("DEBUG") :( |
7ea00c5
to
9debeca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests need updates, there are many tests for background tasks waiting on specific log messages.
pkg/cli/server/root.go
Outdated
@@ -321,7 +321,7 @@ func validateExtensionsConfig(cfg *config.Config, log zlog.Logger) error { | |||
//nolint:lll | |||
if subPath.StorageDriver != nil && cfg.Extensions != nil && cfg.Extensions.Search != nil && | |||
cfg.Extensions.Search.Enable != nil && *cfg.Extensions.Search.Enable && cfg.Extensions.Search.CVE != nil { | |||
log.Error().Err(zerr.ErrBadConfig).Msg("CVE functionality can't be used with remote storage. Please disable CVE") | |||
log.Error().Err(zerr.ErrBadConfig).Msg("cveCVE functionality can't be used with remote storage. Please disable cve") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error().Err(zerr.ErrBadConfig).Msg("cveCVE functionality can't be used with remote storage. Please disable cve") | |
log.Error().Err(zerr.ErrBadConfig).Msg("cve functionality can't be used with remote storage. Please disable cve") |
pkg/extensions/extension_search.go
Outdated
@@ -59,7 +59,7 @@ func EnableSearchExtension(conf *config.Config, storeController storage.StoreCon | |||
func downloadTrivyDB(interval time.Duration, sch *scheduler.Scheduler, cveScanner CveScanner, log log.Logger) { | |||
generator := cveinfo.NewDBUpdateTaskGenerator(interval, cveScanner, log) | |||
|
|||
log.Info().Msg("Submitting CVE DB update scheduler") | |||
log.Info().Msg("submitting CVE DB update scheduler") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info().Msg("submitting CVE DB update scheduler") | |
log.Info().Msg("submitting CVE DB update generator to scheduler") |
Was my mistake
pkg/extensions/extension_search.go
Outdated
@@ -68,7 +68,7 @@ func startScanner(interval time.Duration, metaDB mTypes.MetaDB, sch *scheduler.S | |||
) { | |||
generator := cveinfo.NewScanTaskGenerator(metaDB, cveScanner, log) | |||
|
|||
log.Info().Msg("Submitting CVE scan scheduler") | |||
log.Info().Msg("submitting CVE scan scheduler") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info().Msg("submitting CVE scan scheduler") | |
log.Info().Msg("submitting CVE scan generator to scheduler") |
pkg/extensions/search/cve/scan.go
Outdated
) scheduler.TaskGenerator { | ||
sublogger := logC.With().Str("component", "search").Logger() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use component cve
instead? These are background tasks after all.
sublogger := logC.With().Str("component", "search").Logger() | |
sublogger := logC.With().Str("component", "cve").Logger() |
@@ -56,7 +56,7 @@ func ParseRepo(repo string, metaDB mTypes.MetaDB, storeController storage.StoreC | |||
|
|||
indexBlob, err := imageStore.GetIndexContent(repo) | |||
if err != nil { | |||
log.Error().Err(err).Str("repository", repo).Msg("load-repo: failed to read index.json for repo") | |||
log.Error().Err(err).Str("repository", repo).Msg("failed to read index.json for repo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error().Err(err).Str("repository", repo).Msg("failed to read index.json for repo") | |
log.Error().Err(err).Str("component", "metadb").Str("repository", repo).Msg("failed to read index.json for repo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to automate this better by creating a per-component sublogger. Let's do this in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just keep the file name and line number in the log msg? Instead of using a component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"component" would be a nice column to index
Many files map to a single component and they may get refactored around.
@@ -294,14 +294,14 @@ func getNotationSignatureLayersInfo( | |||
var manifestContent ispec.Manifest | |||
if err := json.Unmarshal(manifestBlob, &manifestContent); err != nil { | |||
log.Error().Err(err).Str("repository", repo).Str("reference", manifestDigest).Msg( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error().Err(err).Str("repository", repo).Str("reference", manifestDigest).Msg( | |
log.Error().Err(err).Str("component", "metadb").Str("repository", repo).Str("reference", manifestDigest).Msg( |
@@ -294,14 +294,14 @@ func getNotationSignatureLayersInfo( | |||
var manifestContent ispec.Manifest | |||
if err := json.Unmarshal(manifestBlob, &manifestContent); err != nil { | |||
log.Error().Err(err).Str("repository", repo).Str("reference", manifestDigest).Msg( | |||
"load-repo: unable to marshal blob index") | |||
"failed to marshal blob index") | |||
|
|||
return layers, err | |||
} | |||
|
|||
if len(manifestContent.Layers) != 1 { | |||
log.Error().Err(zerr.ErrBadManifest).Str("repository", repo).Str("reference", manifestDigest). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error().Err(zerr.ErrBadManifest).Str("repository", repo).Str("reference", manifestDigest). | |
log.Error().Err(zerr.ErrBadManifest).Str("component", "metadb").Str("repository", repo).Str("reference", manifestDigest). |
@@ -316,7 +316,7 @@ func getNotationSignatureLayersInfo( | |||
layerContent, err := imageStore.GetBlobContent(repo, layer) | |||
if err != nil { | |||
log.Error().Err(err).Str("repository", repo).Str("reference", manifestDigest).Str("layerDigest", layer.String()).Msg( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error().Err(err).Str("repository", repo).Str("reference", manifestDigest).Str("layerDigest", layer.String()).Msg( | |
log.Error().Err(err).Str("component", "metadb").Str("repository", repo).Str("reference", manifestDigest).Str("layerDigest", layer.String()).Msg( |
pkg/storage/imagestore/imagestore.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peusebiu please double check if the errors in this file are errors or warnings.
pkg/scheduler/scheduler.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these error messages I would add the component, as they may be confusing for someone not familiar with the code when looking at the log messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to refactoring this better. How to pass a sublogger into a "component"
896820a
to
6feaf51
Compare
cb7e0c7
to
c46aa1e
Compare
Signed-off-by: Ramkumar Chinchani <[email protected]>
Closing this in favor on #2045 |
What type of PR is this?
Which issue does this PR fix:
What does this PR do / Why do we need it:
If an issue # is not available please add repro steps and logs showing the issue:
Testing done on this change:
Automation added to e2e:
Will this break upgrades or downgrades?
Does this PR introduce any user-facing change?:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.